package cn.laixueit.service.impl;

import cn.laixueit.mapper.ClassesMapper;
import cn.laixueit.mapper.StudentMapper;
import cn.laixueit.mapper.TeacherMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class CountService {

    @Autowired
    private ClassesMapper classesMapper;
    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private TeacherMapper teacherMapper;

    public Map<String, Integer> count() {
        HashMap<String, Integer> map = new HashMap<>();

        Long countTeacher = teacherMapper.countByExample(null);
        Long countStudent = studentMapper.countByExample(null);
        Integer countPerson = countStudent.intValue() + countTeacher.intValue();
        Long countClasses = classesMapper.countByExample(null);

        Integer countStudentIsSchool = studentMapper.findCountStudentIsSchool();

        map.put("countPerson",countPerson);
        map.put("countStudent",countStudent.intValue());
        map.put("countTeacher",countTeacher.intValue());
        map.put("countClasses",countClasses.intValue());
        map.put("countStudentIsSchool",countStudentIsSchool);
        return map;
    }
}
